import * as XLSX from 'xlsx'

// 导出excel
// list = { data, sheetname }
export function json2Excel (list: Array<{ data: object[], sheetname: string }>, filename: string): void {
  const wb = XLSX.utils.book_new()
  list.forEach(({ data, sheetname }) => {
    const ws = XLSX.utils.json_to_sheet(data)
    XLSX.utils.book_append_sheet(wb, ws, sheetname)
  })
  XLSX.writeFile(wb, `${filename}.xlsx`)
}

